package com.sjzl.entity;

import java.util.ArrayList;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

@Entity
@Table(name="tb_reply")
public class Reply extends BaseEntity {
	private Post post;
	private String name;
	private String content;
	private Integer floor;//回帖楼数
	private User user;
	
	private Reply reply;
	private List<Reply> subReply = new ArrayList<Reply>();
	
	@ManyToOne
	public Post getPost() {
		return post;
	}
	public void setPost(Post post) {
		this.post = post;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	
	@Column(length=20000000)
	public String getContent() {
		return content;
	}
	public void setContent(String content) {
		this.content = content;
	}
	
	public Integer getFloor() {
		return floor;
	}
	public void setFloor(Integer floor) {
		this.floor = floor;
	}
	
	@ManyToOne
	public User getUser() {
		return user;
	}
	public void setUser(User user) {
		this.user = user;
	}
	
	@ManyToOne(fetch = FetchType.EAGER, cascade = CascadeType.REMOVE)
	@JoinColumn(name="parent_id")
	public Reply getReply() {
		return reply;
	}
	public void setReply(Reply reply) {
		this.reply = reply;
	}
	
	@OneToMany(fetch = FetchType.EAGER, mappedBy="reply", cascade = CascadeType.REMOVE)
	public List<Reply> getSubReply() {
		return subReply;
	}
	public void setSubReply(List<Reply> subReply) {
		this.subReply = subReply;
	}
	
}
